package com.ry.bhwktapp.home.ui
//TODO  可变集合的使用
// 可变集合
//不可变集合变成可变集合
//可变集合变成不可变集合
fun main() {
//    可变集合
    val mutableListOf = mutableListOf<String>("刘", "关", "张")
    //新增
    mutableListOf.add("赵")
    //删除
    mutableListOf.remove("张")
    //修改
    mutableListOf.set(0,"刘禅")

    println(mutableListOf[0])
    println(mutableListOf[2])
    println(mutableListOf.getOrNull(4))


    //不可变集合转化为可变集合
    val listOf = listOf<String>("aa", "bb", "cc")
    val toMutableList = listOf.toMutableList()
    toMutableList.add("dd")
    println(toMutableList[3])

    //可变集合转化为不可变集合
    val toList = toMutableList.toList()
//    toList.add
}